﻿using Pulog.Models;
using System.Linq;
using System.Collections.Generic;

namespace Pulog.Models
{
    public partial class LinkRepository : ILinkRepository
    {
        private readonly PulogDataContext dc = new PulogDataContext();

        #region ILinkRepository Members

        public List<Link> GetAllLinks()
        {
            return dc.Links.ToList<Link>();
        }

        public Link GetLinkByID(int id)
        {
            return dc.Links.Single(l => l.linkID == id);
        }

        public void AddLink(Link link)
        {
            dc.Links.InsertOnSubmit(link);
        }

        public void DeleteLink(Link link)
        {
            dc.Links.DeleteOnSubmit(link);
        }

        // Persistence 
        public void Save()
        {
            dc.SubmitChanges();
        }

        #endregion
    }
}